importPackage(Packages.aurelienribon.tweenengine);
importPackage(Packages.aurelienribon.tweenengine.equations);

var Timeline=Packages.aurelienribon.tweenengine.Timeline;
var Tween=Packages.aurelienribon.tweenengine.Tween;
var Linear=Packages.aurelienribon.tweenengine.equations.Linear.INOUT;

var scheduler=new Object();
scheduler.getSize=function(){
	return 1;
}

scheduler.getTimes=function(){
	return [0];
}

scheduler.getParameters=function(){
	return new Array();
}

scheduler.getMethods=function(){
	return ["step1"];
}

scheduler.step1=function(stage){
	
	var sender=stage.getSourcePosition();
	var target=stage.getTargetPosition();
	
	var createTimeline=function(t){
		var timeline=Timeline.createSequence().beginSequence();
		
		timeline.push(Tween.to(t,1,3).target(x,y).waypoint(0,300).ease(Linear));
		
		timeline.end();
		
		return timeline;
	}
	

	for(var i=0;i<stage.getMissileCount();i++){
	
		var y=Math.random()*200+50+stage.getTrackOffset();
		var x=Math.random()*300-150+target.x;
		
		// create an actor that rushes to other player
		var actor=stage.createSpecialMissileActor();
		actor.setMissileType(1);
		actor.setModelPosition(sender.x,sender.y);
		
		stage.tweenSpecialMissileActor(actor,createTimeline(actor));
		
		// create virtual actor for prediction
		var virtualActor=stage.createVirtualSpecialMissileActor(actor);
		virtualActor.setPosition(sender.x,sender.y);
		stage.tweenVirtualSpecialMissileActor(virtualActor,createTimeline(virtualActor));
	}
	
}
